from PIL import Image

# 打开图像文件
image = Image.open("../temp/input_image.jpg")

# 缩放图像
width, height = image.size
new_width = width // 2
new_height = height // 2
resized_image = image.resize((new_width, new_height))

# 裁剪图像
left = new_width // 4
top = new_height // 4
right = 3 * new_width // 4
bottom = 3 * new_height // 4
cropped_image = resized_image.crop((left, top, right, bottom))

# 旋转图像
rotated_image = cropped_image.rotate(90)  # 旋转90度

# 颜色转换
grayscale_image = rotated_image.convert("L")  # 转换为灰度图像

# 保存处理后的图像
grayscale_image.save("../temp/output_image.jpg")
